/*********************************************************************
	Rhapsody	: 7.6
	Login		: Ryszard
	Component	: DefaultComponent
	Configuration 	: DefaultConfig
	Model Element	: ScheduleApplication
//!	Generated Date	: Wed, 23, Nov 2011 
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/ScheduleApplication.java
*********************************************************************/

package CargoLiftSystem;

//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;

//----------------------------------------------------------------------------
// CargoLiftSystem/ScheduleApplication.java                                                                  
//----------------------------------------------------------------------------

//## package CargoLiftSystem 


//## class ScheduleApplication 
public class ScheduleApplication implements RiJStateConcept {
    
    public Reactive reactive;		//## ignore 
    
    protected boolean[] requestedFloors;		//## attribute requestedFloors 
    
    protected java.util.Queue<Integer> liftCalls;		//## attribute liftCalls 
    
    protected int nextFloor;		//## attribute nextFloor 
    
    protected int requestedFloor;		//## attribute requestedFloor 
    
    protected java.util.Queue<Integer> selectedFloors;		//## attribute selectedFloors 
    
    protected boolean stop;		//## attribute stop 
    
    protected Lift itsLift;		//## link itsLift 
    
    //#[ ignore 
    public static final int RiJNonState=0;
    public static final int activeScheduler=1;
    public static final int state_9=2;
    public static final int waitingForLift=3;
    public static final int sensorDetectedNextFloor=4;
    public static final int liftStopping=5;
    public static final int liftArrived=6;
    public static final int emptyTaskList=7;
    public static final int doorsOpen=8;
    public static final int doorsClosed=9;
    public static final int awaitingTasksGenerated=10;
    public static final int state_8=11;
    public static final int liftCalled=12;
    public static final int awaitingForCall=13;
    public static final int state_16=14;
    public static final int floorSelected=15;
    public static final int awaitingForFloorSelection=16;
    //#]
    protected int rootState_subState;		//## ignore 
    
    protected int rootState_active;		//## ignore 
    
    protected int state_9_subState;		//## ignore 
    
    protected int state_9_active;		//## ignore 
    
    protected int state_8_subState;		//## ignore 
    
    protected int state_8_active;		//## ignore 
    
    protected int state_16_subState;		//## ignore 
    
    protected int state_16_active;		//## ignore 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public boolean isIn(int state) {
        return reactive.isIn(state);
    }
    
    //## statechart_method 
    public boolean isCompleted(int state) {
        return reactive.isCompleted(state);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  ScheduleApplication(RiJThread p_thread) {
        reactive = new Reactive(p_thread);
    }
    
    //## operation getRequestedFloors() 
    public boolean[] getRequestedFloors() {
        //#[ operation getRequestedFloors() 
        return requestedFloors;
        //#]
    }
    
    /**
     * @param floor
    */
    //## operation hasCallForFloor(int) 
    public boolean hasCallForFloor(int floor) {
        //#[ operation hasCallForFloor(int) 
        if(requestedFloors[floor]==true)
        	return true;
        else 
        	return false;
        //#]
    }
    
    /**
     * @param floor
    */
    //## operation removeFloor(int) 
    public void removeFloor(int floor) {
        //#[ operation removeFloor(int) 
             requestedFloors[floor]=false;
        //#]
    }
    
    //## operation resetRequests() 
    public void resetRequests() {
        //#[ operation resetRequests() 
        for(int i=0; i<requestedFloors.length; i++)
        {
         	requestedFloors[i] = false;
        }
        //#]
    }
    
    //## auto_generated 
    private void setRequestedFloors(int i1, boolean p_requestedFloors) {
        requestedFloors[i1] = p_requestedFloors;
    }
    
    //## auto_generated 
    public java.util.Queue<Integer> getLiftCalls() {
        return liftCalls;
    }
    
    //## auto_generated 
    public void setLiftCalls(java.util.Queue<Integer> p_liftCalls) {
        liftCalls = p_liftCalls;
    }
    
    //## auto_generated 
    public int getNextFloor() {
        return nextFloor;
    }
    
    //## auto_generated 
    public void setNextFloor(int p_nextFloor) {
        nextFloor = p_nextFloor;
    }
    
    //## auto_generated 
    public int getRequestedFloor() {
        return requestedFloor;
    }
    
    //## auto_generated 
    public void setRequestedFloor(int p_requestedFloor) {
        requestedFloor = p_requestedFloor;
    }
    
    //## auto_generated 
    public java.util.Queue<Integer> getSelectedFloors() {
        return selectedFloors;
    }
    
    //## auto_generated 
    public void setSelectedFloors(java.util.Queue<Integer> p_selectedFloors) {
        selectedFloors = p_selectedFloors;
    }
    
    //## auto_generated 
    public boolean getStop() {
        return stop;
    }
    
    //## auto_generated 
    public void setStop(boolean p_stop) {
        stop = p_stop;
    }
    
    //## auto_generated 
    public Lift getItsLift() {
        return itsLift;
    }
    
    //## auto_generated 
    public void __setItsLift(Lift p_Lift) {
        itsLift = p_Lift;
    }
    
    //## auto_generated 
    public void _setItsLift(Lift p_Lift) {
        if(itsLift != null)
            {
                itsLift.__setItsScheduleApplication(null);
            }
        __setItsLift(p_Lift);
    }
    
    //## auto_generated 
    public void setItsLift(Lift p_Lift) {
        if(p_Lift != null)
            {
                p_Lift._setItsScheduleApplication(this);
            }
        _setItsLift(p_Lift);
    }
    
    //## auto_generated 
    public void _clearItsLift() {
        itsLift = null;
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = false;
        done = reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
            initStatechart();
        }
        
        //## statechart_method 
        public boolean isIn(int state) {
            if(state_16 == state)
                {
                    return isIn(activeScheduler);
                }
            if(state_16_subState == state)
                {
                    return true;
                }
            if(state_8 == state)
                {
                    return isIn(activeScheduler);
                }
            if(state_8_subState == state)
                {
                    return true;
                }
            if(state_9 == state)
                {
                    return isIn(activeScheduler);
                }
            if(state_9_subState == state)
                {
                    return true;
                }
            if(rootState_subState == state)
                {
                    return true;
                }
            return false;
        }
        
        //## statechart_method 
        public boolean isCompleted(int state) {
            return true;
        }
        
        //## statechart_method 
        public void rootState_entDef() {
            {
                rootState_enter();
                rootStateEntDef();
            }
        }
        
        //## statechart_method 
        public int rootState_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(rootState_active == activeScheduler)
                {
                    res = activeScheduler_dispatchEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int activeScheduler_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(state_8_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeScheduler))
                        {
                            return res;
                        }
                }
            if(state_9_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeScheduler))
                        {
                            return res;
                        }
                }
            if(state_16_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(activeScheduler))
                        {
                            return res;
                        }
                }
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = activeScheduler_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int state_9_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_9_active) {
                case emptyTaskList:
                {
                    res = emptyTaskList_takeEvent(id);
                }
                break;
                case awaitingTasksGenerated:
                {
                    res = awaitingTasksGenerated_takeEvent(id);
                }
                break;
                case liftArrived:
                {
                    res = liftArrived_takeEvent(id);
                }
                break;
                case sensorDetectedNextFloor:
                {
                    res = sensorDetectedNextFloor_takeEvent(id);
                }
                break;
                case waitingForLift:
                {
                    res = waitingForLift_takeEvent(id);
                }
                break;
                case liftStopping:
                {
                    res = liftStopping_takeEvent(id);
                }
                break;
                case doorsOpen:
                {
                    res = doorsOpen_takeEvent(id);
                }
                break;
                case doorsClosed:
                {
                    res = doorsClosed_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public int state_8_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_8_active) {
                case awaitingForCall:
                {
                    res = awaitingForCall_takeEvent(id);
                }
                break;
                case liftCalled:
                {
                    res = liftCalled_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public int state_16_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_16_active) {
                case awaitingForFloorSelection:
                {
                    res = awaitingForFloorSelection_takeEvent(id);
                }
                break;
                case floorSelected:
                {
                    res = floorSelected_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## auto_generated 
        protected void initStatechart() {
            rootState_subState = RiJNonState;
            rootState_active = RiJNonState;
            state_9_subState = RiJNonState;
            state_9_active = RiJNonState;
            state_8_subState = RiJNonState;
            state_8_active = RiJNonState;
            state_16_subState = RiJNonState;
            state_16_active = RiJNonState;
        }
        
        //## statechart_method 
        public void floorSelectedExit() {
        }
        
        //## statechart_method 
        public void liftCalled_enter() {
            pushNullConfig();
            state_8_subState = liftCalled;
            state_8_active = liftCalled;
            liftCalledEnter();
        }
        
        //## statechart_method 
        public void state_8_enter() {
            state_8Enter();
        }
        
        //## statechart_method 
        public void awaitingTasksGeneratedEnter() {
            //#[ state ROOT.activeScheduler.state_9.awaitingTasksGenerated.(Entry) 
            requestedFloor = liftCalls.poll();
            //#]
        }
        
        //## statechart_method 
        public void doorsClosed_enter() {
            pushNullConfig();
            state_9_subState = doorsClosed;
            state_9_active = doorsClosed;
            doorsClosedEnter();
        }
        
        //## statechart_method 
        public int liftArrived_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(OpenDoors.OpenDoors_CargoLiftSystem_id))
                {
                    res = liftArrivedTakeOpenDoors();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void waitingForLift_enter() {
            state_9_subState = waitingForLift;
            state_9_active = waitingForLift;
            waitingForLiftEnter();
        }
        
        //## statechart_method 
        public void awaitingForFloorSelectionEnter() {
        }
        
        //## statechart_method 
        public int liftCalledTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            liftCalled_exit();
            awaitingForCall_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_entDef() {
            awaitingTasksGenerated_enter();
        }
        
        //## statechart_method 
        public int doorsOpenTakedoorClosed() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            doorsOpen_exit();
            doorsClosed_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_9_enter() {
            state_9Enter();
        }
        
        //## statechart_method 
        public int awaitingForFloorSelectionTakeSelectFloor() {
            SelectFloor params = (SelectFloor) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            awaitingForFloorSelection_exit();
            //#[ transition 7 
            if(!selectedFloors.contains(params.floor))selectedFloors.add(params.floor);
            //#]
            floorSelected_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_16_entDef() {
            state_16_enter();
            state_16EntDef();
        }
        
        //## statechart_method 
        public void awaitingForCallExit() {
        }
        
        //## statechart_method 
        public int doorsClosedTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            {
                doorsClosed_exit();
                awaitingTasksGenerated_entDef();
                res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            }
            return res;
        }
        
        //## statechart_method 
        public void waitingForLiftEnter() {
        }
        
        //## statechart_method 
        public void state_9_entDef() {
            state_9_enter();
            state_9EntDef();
        }
        
        //## statechart_method 
        public void awaitingForCall_enter() {
            state_8_subState = awaitingForCall;
            state_8_active = awaitingForCall;
            awaitingForCallEnter();
        }
        
        //## statechart_method 
        public void state_8EntDef() {
            //#[ transition 3 
            liftCalls = new java.util.LinkedList<Integer>();
            //#]
            awaitingForCall_entDef();
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_exit() {
            popNullConfig();
            awaitingTasksGeneratedExit();
        }
        
        //## statechart_method 
        public void doorsOpen_entDef() {
            doorsOpen_enter();
        }
        
        //## statechart_method 
        public void liftStoppingEnter() {
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloorEnter() {
            //#[ state ROOT.activeScheduler.state_9.sensorDetectedNextFloor.(Entry) 
            if(selectedFloors.contains(nextFloor)) stop = true;
            else stop = false;
            //#]
        }
        
        //## statechart_method 
        public int state_9_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_exit() {
            awaitingForFloorSelectionExit();
        }
        
        //## statechart_method 
        public void floorSelectedEnter() {
        }
        
        //## statechart_method 
        public void state_16Enter() {
        }
        
        //## statechart_method 
        public int doorsClosed_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = doorsClosedTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void doorsClosed_entDef() {
            doorsClosed_enter();
        }
        
        //## statechart_method 
        public void liftArrivedEnter() {
        }
        
        //## statechart_method 
        public void waitingForLift_entDef() {
            waitingForLift_enter();
        }
        
        //## statechart_method 
        public void state_9EntDef() {
            emptyTaskList_entDef();
        }
        
        //## statechart_method 
        public int awaitingForFloorSelection_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(SelectFloor.SelectFloor_CargoLiftSystem_id))
                {
                    res = awaitingForFloorSelectionTakeSelectFloor();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_16_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void floorSelected_enter() {
            pushNullConfig();
            state_16_subState = floorSelected;
            state_16_active = floorSelected;
            floorSelectedEnter();
        }
        
        //## statechart_method 
        public void state_16_enter() {
            state_16Enter();
        }
        
        //## statechart_method 
        public int liftStoppingTakeLiftArrived() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            liftStopping_exit();
            liftArrived_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void waitingForLift_exit() {
            waitingForLiftExit();
        }
        
        //## statechart_method 
        public int doorsOpen_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(doorClosed.doorClosed_CargoLiftSystem_id))
                {
                    res = doorsOpenTakedoorClosed();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftStopping_exit() {
            liftStoppingExit();
        }
        
        //## statechart_method 
        public void liftStoppingExit() {
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_exit() {
            popNullConfig();
            sensorDetectedNextFloorExit();
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_enter() {
            pushNullConfig();
            state_9_subState = sensorDetectedNextFloor;
            state_9_active = sensorDetectedNextFloor;
            sensorDetectedNextFloorEnter();
        }
        
        //## statechart_method 
        public int rootState_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void floorSelected_exit() {
            popNullConfig();
            floorSelectedExit();
        }
        
        //## statechart_method 
        public void state_16_exit() {
            switch (state_16_subState) {
                case awaitingForFloorSelection:
                {
                    awaitingForFloorSelection_exit();
                }
                break;
                case floorSelected:
                {
                    floorSelected_exit();
                }
                break;
                default:
                    break;
            }
            state_16_subState = RiJNonState;
            state_16Exit();
        }
        
        //## statechart_method 
        public void doorsClosedEnter() {
        }
        
        //## statechart_method 
        public void liftArrived_exit() {
            liftArrivedExit();
        }
        
        //## statechart_method 
        public int liftStopping_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(LiftArrived.LiftArrived_CargoLiftSystem_id))
                {
                    res = liftStoppingTakeLiftArrived();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void waitingForLiftExit() {
        }
        
        //## statechart_method 
        public void state_16EntDef() {
            //#[ transition 6 
            selectedFloors = new java.util.LinkedList<Integer>();
            //#]
            awaitingForFloorSelection_entDef();
        }
        
        //## statechart_method 
        public void emptyTaskListExit() {
        }
        
        //## statechart_method 
        public void activeScheduler_enter() {
            rootState_subState = activeScheduler;
            rootState_active = activeScheduler;
            activeSchedulerEnter();
        }
        
        //## statechart_method 
        public void rootState_enter() {
            rootStateEnter();
        }
        
        //## statechart_method 
        public void rootStateEnter() {
        }
        
        //## statechart_method 
        public void awaitingForFloorSelectionExit() {
        }
        
        //## statechart_method 
        public int floorSelected_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = floorSelectedTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_16_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int liftCalled_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = liftCalledTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_8_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int state_8_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int emptyTaskList_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(CallLift.CallLift_CargoLiftSystem_id))
                {
                    res = emptyTaskListTakeCallLift();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftArrived_entDef() {
            liftArrived_enter();
        }
        
        //## statechart_method 
        public void liftStopping_entDef() {
            liftStopping_enter();
        }
        
        //## statechart_method 
        public int sensorDetectedNextFloor_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = sensorDetectedNextFloorTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloor_entDef() {
            sensorDetectedNextFloor_enter();
        }
        
        //## statechart_method 
        public void state_9Enter() {
        }
        
        //## statechart_method 
        public void liftCalledEnter() {
        }
        
        //## statechart_method 
        public void state_8Enter() {
        }
        
        //## statechart_method 
        public void doorsClosed_exit() {
            popNullConfig();
            doorsClosedExit();
        }
        
        //## statechart_method 
        public void doorsOpenEnter() {
        }
        
        //## statechart_method 
        public int liftArrivedTakeOpenDoors() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            liftArrived_exit();
            doorsOpen_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int waitingForLiftTakeLiftArrived() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            waitingForLift_exit();
            liftArrived_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int waitingForLiftTakeLocationDetectorSignal() {
            LocationDetectorSignal params = (LocationDetectorSignal) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            waitingForLift_exit();
            //#[ transition 9 
            nextFloor = params.floor;
            //#]
            sensorDetectedNextFloor_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public int floorSelectedTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            floorSelected_exit();
            awaitingForFloorSelection_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void emptyTaskList_enter() {
            state_9_subState = emptyTaskList;
            state_9_active = emptyTaskList;
            emptyTaskListEnter();
        }
        
        //## statechart_method 
        public int sensorDetectedNextFloorTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            //## transition 10 
            if(stop == true)
                {
                    sensorDetectedNextFloor_exit();
                    liftStopping_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            else
                {
                    //## transition 11 
                    if(stop == false)
                        {
                            sensorDetectedNextFloor_exit();
                            waitingForLift_entDef();
                            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                        }
                }
            return res;
        }
        
        //## statechart_method 
        public void rootStateEntDef() {
            activeScheduler_entDef();
        }
        
        //## statechart_method 
        public void state_16Exit() {
        }
        
        //## statechart_method 
        public void awaitingForCallEnter() {
        }
        
        //## statechart_method 
        public int awaitingTasksGeneratedTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            awaitingTasksGenerated_exit();
            waitingForLift_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_9_exit() {
            switch (state_9_subState) {
                case emptyTaskList:
                {
                    emptyTaskList_exit();
                }
                break;
                case awaitingTasksGenerated:
                {
                    awaitingTasksGenerated_exit();
                }
                break;
                case liftArrived:
                {
                    liftArrived_exit();
                }
                break;
                case sensorDetectedNextFloor:
                {
                    sensorDetectedNextFloor_exit();
                }
                break;
                case waitingForLift:
                {
                    waitingForLift_exit();
                }
                break;
                case liftStopping:
                {
                    liftStopping_exit();
                }
                break;
                case doorsOpen:
                {
                    doorsOpen_exit();
                }
                break;
                case doorsClosed:
                {
                    doorsClosed_exit();
                }
                break;
                default:
                    break;
            }
            state_9_subState = RiJNonState;
            state_9Exit();
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_enter() {
            state_16_subState = awaitingForFloorSelection;
            state_16_active = awaitingForFloorSelection;
            awaitingForFloorSelectionEnter();
        }
        
        //## statechart_method 
        public int awaitingForCall_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(CallLift.CallLift_CargoLiftSystem_id))
                {
                    res = awaitingForCallTakeCallLift();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_8_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void liftCalled_exit() {
            popNullConfig();
            liftCalledExit();
        }
        
        //## statechart_method 
        public void liftCalledExit() {
        }
        
        //## statechart_method 
        public void liftCalled_entDef() {
            liftCalled_enter();
        }
        
        //## statechart_method 
        public void state_8_exit() {
            switch (state_8_subState) {
                case awaitingForCall:
                {
                    awaitingForCall_exit();
                }
                break;
                case liftCalled:
                {
                    liftCalled_exit();
                }
                break;
                default:
                    break;
            }
            state_8_subState = RiJNonState;
            state_8Exit();
        }
        
        //## statechart_method 
        public void state_8_entDef() {
            state_8_enter();
            state_8EntDef();
        }
        
        //## statechart_method 
        public void doorsOpen_exit() {
            doorsOpenExit();
        }
        
        //## statechart_method 
        public void doorsOpen_enter() {
            state_9_subState = doorsOpen;
            state_9_active = doorsOpen;
            doorsOpenEnter();
        }
        
        //## statechart_method 
        public int emptyTaskListTakeCallLift() {
            CallLift params = (CallLift) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            emptyTaskList_exit();
            awaitingTasksGenerated_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void emptyTaskListEnter() {
        }
        
        //## statechart_method 
        public void emptyTaskList_entDef() {
            emptyTaskList_enter();
        }
        
        //## statechart_method 
        public int waitingForLift_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(LiftArrived.LiftArrived_CargoLiftSystem_id))
                {
                    res = waitingForLiftTakeLiftArrived();
                }
            else if(event.isTypeOf(LocationDetectorSignal.LocationDetectorSignal_CargoLiftSystem_id))
                {
                    res = waitingForLiftTakeLocationDetectorSignal();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void activeSchedulerEnter() {
        }
        
        //## statechart_method 
        public void activeScheduler_entDef() {
            activeScheduler_enter();
            state_8_entDef();
            state_9_entDef();
            state_16_entDef();
        }
        
        //## statechart_method 
        public void floorSelected_entDef() {
            floorSelected_enter();
        }
        
        //## statechart_method 
        public int state_16_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void awaitingTasksGeneratedExit() {
        }
        
        //## statechart_method 
        public void awaitingTasksGenerated_enter() {
            pushNullConfig();
            state_9_subState = awaitingTasksGenerated;
            state_9_active = awaitingTasksGenerated;
            awaitingTasksGeneratedEnter();
        }
        
        //## statechart_method 
        public int activeScheduler_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void rootStateExit() {
        }
        
        //## statechart_method 
        public void awaitingForCall_exit() {
            awaitingForCallExit();
        }
        
        //## statechart_method 
        public void state_8Exit() {
        }
        
        //## statechart_method 
        public void doorsOpenExit() {
        }
        
        //## statechart_method 
        public void liftArrived_enter() {
            state_9_subState = liftArrived;
            state_9_active = liftArrived;
            liftArrivedEnter();
        }
        
        //## statechart_method 
        public void sensorDetectedNextFloorExit() {
        }
        
        //## statechart_method 
        public void activeSchedulerExit() {
        }
        
        //## statechart_method 
        public void awaitingForFloorSelection_entDef() {
            awaitingForFloorSelection_enter();
        }
        
        //## statechart_method 
        public int awaitingForCallTakeCallLift() {
            CallLift params = (CallLift) event;
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            awaitingForCall_exit();
            //#[ transition 4 
            if(!liftCalls.contains(params.floor))
            liftCalls.offer(params.floor);
            //#]
            liftCalled_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void awaitingForCall_entDef() {
            awaitingForCall_enter();
        }
        
        //## statechart_method 
        public int awaitingTasksGenerated_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = awaitingTasksGeneratedTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_9_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void doorsClosedExit() {
        }
        
        //## statechart_method 
        public void emptyTaskList_exit() {
            emptyTaskListExit();
        }
        
        //## statechart_method 
        public void liftArrivedExit() {
        }
        
        //## statechart_method 
        public void liftStopping_enter() {
            state_9_subState = liftStopping;
            state_9_active = liftStopping;
            liftStoppingEnter();
        }
        
        //## statechart_method 
        public void state_9Exit() {
        }
        
        //## statechart_method 
        public void activeScheduler_exit() {
            state_8_exit();
            state_9_exit();
            state_16_exit();
            activeSchedulerExit();
        }
        
    }
}
/*********************************************************************
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/ScheduleApplication.java
*********************************************************************/

